package cn.tedu.jdbc;



import java.sql.*;
import java.util.Scanner;

public class get2 {
    public static void main(String[] args) throws Exception {


            Class.forName("com.mysql.cj.jdbc.Driver");
            String url ="jdbc:mysql://localhost:3306/gdb2109";
            Connection con = DriverManager.getConnection(url, "root", "root");
            String name = new Scanner(System.in).nextLine();
            String pwd = new Scanner(System.in).nextLine();
            String sql = "select * from user2 where name=? and password=?";
            PreparedStatement ps = con.prepareStatement(sql);
            ps.setString(1,name);
            ps.setString(2,pwd);
            ResultSet rs = ps.executeQuery();
            if(rs.next()){
                System.out.println("登陆成功");
            }else{
                System.out.println("登录失败");
            }

            rs.close();
            ps.close();
            con.close();







    }
}
